﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Survey.Model.SurveyEntities
{
    public class AlternativeAnswer: Answer, IAnswer
    {
        public virtual IList<bool> checkedAlternatives { get; set; }
        public virtual IList<String> AnswerStatements { get; set; }
        public virtual bool IsMultipleAnswers { get; set; }

        public AlternativeAnswer(): base()
        {
            AnswerStatements = new List<String>();
            checkedAlternatives = new List<bool>();
        }

        public AlternativeAnswer(IList<bool> answers)
        {
            AnswerStatements = new List<String>();
            checkedAlternatives = (List<bool>) answers;
        }

        public virtual String GetString()
        {
            StringBuilder returnString = new StringBuilder();
            IEnumerator<bool> answersEnumerator = checkedAlternatives.GetEnumerator();
            while (answersEnumerator.MoveNext())
            {
                returnString.Append(answersEnumerator.Current.ToString());
                returnString.Append(",");
            }
            return returnString.Remove(returnString.Length -1,1).ToString();
        }

        public virtual int GetAnswerType()
        {
            return (int)AnswerType.AlternativeType;
        }
    }
}
